//
//  IMJobBaseInfoView.m
//  Btpin
//
//  Created by Vic on 2019/4/23.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "IMJobBaseInfoView.h"

@interface IMJobBaseInfoView ()
{
    UILabel *titleLbl;
    UILabel *baseInfoLbl;
    UILabel *companyNameLbl;
    UILabel *companyInfoLbl;
    UILabel *wageLbl;
}
@end

@implementation IMJobBaseInfoView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(LeftSpace, 10*Scale, WIDTH-100*Scale, 30*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    titleLbl.font = FontBold(Font_18);
    [self addSubview:titleLbl];
    
    baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(titleLbl), ViewWidth(titleLbl), 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [self addSubview:baseInfoLbl];
    
    companyNameLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(baseInfoLbl), 100, 30*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
    [self addSubview:companyNameLbl];
    
    companyInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(companyNameLbl), StartY(companyNameLbl), WIDTH-80*Scale, ViewHeight(companyNameLbl)) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [self addSubview:companyInfoLbl];
    
    wageLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-200*Scale, 20*Scale, 150*Scale, 20*Scale) text:nil textColor:THEMECOLOR_OF_RED font:Font_15];
    wageLbl.backgroundColor = COLOR_OF_CLEAR;
    wageLbl.textAlignment = NSTextAlignmentRight;
    [self addSubview:wageLbl];
}
- (void)reloadDataModel:(IMJobBaseInfoModel *)model {
    titleLbl.text = model.title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    
    NSString *companyName = (model.companyInfoModel.name&&model.companyInfoModel.name.length)?model.companyInfoModel.name:@" ";
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.companyInfoModel.finance_cn, model.companyInfoModel.scale_cn, model.companyInfoModel.trade_cn];
    wageLbl.text = model.wage_cn;
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 20*Scale) font:Font_15]+1;
    companyNameLbl.frame = CGRectMake(StartX(titleLbl), EndY(baseInfoLbl), MIN(width, (WIDTH-80*Scale)*0.5), 30*Scale);
    companyInfoLbl.frame = CGRectMake(EndX(companyNameLbl), StartY(companyNameLbl), WIDTH-80*Scale-ViewWidth(companyNameLbl), ViewHeight(companyNameLbl));
}

@end
